
import 'dart:io';

import 'package:core_foundation/redux/actions/action_update_themedata.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:redux/redux.dart';

class UtilsCommon {

  static getThemeData(Color color) {
    return ThemeData(primaryColor: color, platform: TargetPlatform.android);
  }

  static dispatchThemeData(Store store, int index) {
    Color color = getColors()[index];
    ThemeData themeData = getThemeData(color);
    store.dispatch(ActionUpdateThemeData(themeData));
  }

  static List<Color> getColors() {
    return [Colors.blue, Colors.blueGrey, Colors.green, Colors.white];
  }

  static Future<String> getAppStoragePath() async {
    final Directory extDir = await getApplicationDocumentsDirectory();
    final String dirPath = '${extDir.path}/Pictures/flutter_test';
    await Directory(dirPath).create(recursive: true);
    return dirPath;
  }

  static Future<String> getAppImagePathByTimeStamp() async {
    String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
    String dirPath = await getAppStoragePath();
    return '$dirPath/${timestamp()}.jpg';
  }
}